package cn.iocoder.yudao.module.promotion.dal.mysql.points;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.promotion.controller.admin.points.vo.pointsactivity.PointsActivityExportReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.points.vo.pointsactivity.PointsActivityPageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.points.PointsActivityDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 积分活动 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface PointsActivityMapper extends BaseMapperX<PointsActivityDO> {

    default PageResult<PointsActivityDO> selectPage(PointsActivityPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PointsActivityDO>()
                .likeIfPresent(PointsActivityDO::getName, reqVO.getName())
                .eqIfPresent(PointsActivityDO::getDes, reqVO.getDes())
                .betweenIfPresent(PointsActivityDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(PointsActivityDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(PointsActivityDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PointsActivityDO::getActivityType, reqVO.getActivityType())
                .betweenIfPresent(PointsActivityDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PointsActivityDO::getId));
    }

    default List<PointsActivityDO> selectList(PointsActivityExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PointsActivityDO>()
                .likeIfPresent(PointsActivityDO::getName, reqVO.getName())
                .eqIfPresent(PointsActivityDO::getDes, reqVO.getDes())
                .betweenIfPresent(PointsActivityDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(PointsActivityDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(PointsActivityDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PointsActivityDO::getActivityType, reqVO.getActivityType())
                .betweenIfPresent(PointsActivityDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PointsActivityDO::getId));
    }

    default PageResult<PointsActivityDO> selectPage(PageParam pageParam, Integer status) {
        return selectPage(pageParam, new LambdaQueryWrapperX<PointsActivityDO>()
                .eq(PointsActivityDO::getDeleted,0)
                .eq(PointsActivityDO::getStatus, status));
    }
    default List<PointsActivityDO> selectList(PointsActivityPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PointsActivityDO>()
                .likeIfPresent(PointsActivityDO::getName, reqVO.getName())
                .inIfPresent(PointsActivityDO::getName, reqVO.getNameList())
                .eqIfPresent(PointsActivityDO::getDes, reqVO.getDes())
                .betweenIfPresent(PointsActivityDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(PointsActivityDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(PointsActivityDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PointsActivityDO::getActivityType, reqVO.getActivityType())
                .betweenIfPresent(PointsActivityDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PointsActivityDO::getId));
    }
}
